using System;
using EnvDTE;
using NUnitGenAddIn.Core;

namespace NUnitGenAddIn.VS2008
{
    /// <summary>
    /// Abstract VS2008 <see cref="NUnit"/> Generator Helper Factory
    /// </summary>
    public class VS2008NUnitGenHelperAbstractFactory : NUnitGenHelperAbstractFactory
    {
        /// <summary>
        /// Creates the unit test generator.
        /// </summary>
        /// <param name="addInHelper">The add in helper.</param>
        /// <returns><see cref="UnitTestGenerator"/> object</returns>
        public override UnitTestGenerator CreateUnitTestGenerator(AddInHelper addInHelper)
        {
            if (addInHelper == null)
            {
                throw new ApplicationException("You must create and pass _addInHelper");
            }

            VS2008CodeDomHelper codeDomHelper = new VS2008CodeDomHelper();
            return new VS2008UnitTestGenerator(addInHelper, new UnitTestGeneratorHelper(codeDomHelper),
                                               codeDomHelper);
        }

        /// <summary>
        /// Creates the add in helper.
        /// </summary>
        /// <param name="applicationObject">The application object.</param>
        /// <param name="addInInstance">The add in instance.</param>
        /// <returns><see cref="AddInHelper"/> object</returns>
        public override AddInHelper CreateAddInHelper(DTE applicationObject, AddIn addInInstance)
        {
            return new VS2008AddInHelper(applicationObject, addInInstance);
        }
    }
}